From ca4357e5aa50d4620d20cebaf1a80b579dd997c4 Mon Sep 17 00:00:00 2001 From: "br260@labyrinth.cl.cam.ac.uk" Date: Wed, 12 Nov 2003 17:00:46 +0000 Subject: [PATCH] bitkeeper revision 1.593.1.1 (3fb2673ecxanxs8T80yNhChH3vMCyA) add new domain 0 operation to read console ring in Xen --- .rootkeys | 2 ++ BitKeeper/etc/logging_ok | 1 + tools/internal/Makefile | 1 + tools/internal/xi_read_console_ring.c | 47 +++++++++++++++++++++++++++ xen/common/console.c | 26 +++++++++++++++ xen/common/dom0_ops.c | 8 +++++ xen/common/kernel.c | 16 +++++++++ xen/include/hypervisor-ifs/dom0_ops.h | 12 +++++++ xen/include/xeno/console.h | 16 ++++++++- 9 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 tools/internal/xi_read_console_ring.c create mode 100644 xen/common/console.c diff --git a/.rootkeys b/.rootkeys index c6cb0d2d68..b96338a42b 100644 --- a/.rootkeys +++ b/.rootkeys @@ -170,6 +170,7 @@ 3ec43c5dmQxGDvgJJXbV1yLxT30Y1A tools/internal/xi_helper 3f108ad5wQm0ZaQ4GXFoUhH1W1aW9w tools/internal/xi_list.c 3f0458aaXhD8BQAggO81gv30RQ-ifA tools/internal/xi_phys_grant.c +3fb14ab76b0aJu66S18CVjlemLwk4Q tools/internal/xi_read_console_ring.c 3fa9861aBdNV1yCjfY4cLPr4Mtrpuw tools/internal/xi_restore_linux.c 3fa98615LWZfagwDBp7XfuC-u9wi3w tools/internal/xi_save_linux.c 3f108adb2b5OkKL6-faG3lMiOYDf_w tools/internal/xi_sched_domain.c @@ -239,6 +240,7 @@ 3e397e66AyyD5fYraAySWuwi9uqSXg xen/common/ac_timer.c 3ddb79bddEYJbcURvqqcx99Yl2iAhQ xen/common/block.c 3ddb79bdrqnW93GR9gZk1OJe1qK-iQ xen/common/brlock.c +3fb10d07GscSWPKxBqpvNfU-dYfa0g xen/common/console.c 3fa152581E5KhrAtqZef2Sr5NKTz4w xen/common/debug.c 3ddb79bdLX_P6iB7ILiblRLWvebapg xen/common/dom0_ops.c 3e6377e4i0c9GtKN65e99OtRbw3AZw xen/common/dom_mem_ops.c diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 673d59798e..7c732bc73c 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -6,6 +6,7 @@ akw27@labyrinth.cl.cam.ac.uk akw27@plucky.localdomain bd240@boulderdash.cl.cam.ac.uk bd240@labyrinth.cl.cam.ac.uk +br260@labyrinth.cl.cam.ac.uk br260@laudney.cl.cam.ac.uk iap10@freefall.cl.cam.ac.uk iap10@labyrinth.cl.cam.ac.uk diff --git a/tools/internal/Makefile b/tools/internal/Makefile index 3979cace5b..1a225c0d88 100644 --- a/tools/internal/Makefile +++ b/tools/internal/Makefile @@ -11,6 +11,7 @@ TARGETS = xi_create xi_start xi_stop xi_destroy xi_build TARGETS += xi_phys_grant xi_list xi_save_linux xi_restore_linux TARGETS += xi_sched_global xi_sched_domain xi_usage xi_vif_params TARGETS += xi_vbd_create xi_vbd_add xi_vbd_list xi_vbd_info +TARGETS += xi_read_console_ring INSTALL = $(TARGETS) xi_vifinit xi_helper all: check-for-zlib $(TARGETS) diff --git a/tools/internal/xi_read_console_ring.c b/tools/internal/xi_read_console_ring.c new file mode 100644 index 0000000000..9f28823c20 --- /dev/null +++ b/tools/internal/xi_read_console_ring.c @@ -0,0 +1,47 @@ +/* + * Usage: [-c] + */ + +#include "dom0_defs.h" + +#define CONSOLE_RING_SIZE 16392 +static char *argv0 = "read_console_ring"; + +static long read_console_ring(char *str, unsigned count) +{ + int ret; + dom0_op_t op; + + op.cmd = DOM0_READCONSOLE; + op.u.readconsole.str = str; + op.u.readconsole.count = count; + + ret = do_dom0_op(&op); + if (ret > 0) { + *(str + ret) = '\0'; + } + + return ret; +} + +int main(int argc, char **argv) +{ + char str[CONSOLE_RING_SIZE]; + + if ( argv[0] != NULL ) + argv0 = argv[0]; + + if ( argc > 2) { + fprintf(stderr, "Usage: %s [-r]\n", argv0); + return 1; + } + + if ( read_console_ring(str, CONSOLE_RING_SIZE) < 0 ) { + printf("Read console ring error.\n"); + printf("%s", str); + return 1; + } + + printf("%s", str); + return 0; +} diff --git a/xen/common/console.c b/xen/common/console.c new file mode 100644 index 0000000000..4836dc91d1 --- /dev/null +++ b/xen/common/console.c @@ -0,0 +1,26 @@ +/* + * console.c + * + * read domain console output buffer ring in Xen + * + */ + +#include +#include + +void init_console_ring() +{ + console_ring.len = 0; +} + +long read_console_ring(char *str, unsigned int count) +{ + unsigned int len; + + len = (console_ring.len < count)? console_ring.len : count; + + if ( copy_to_user(str, console_ring.buf, len) ) + return -EFAULT; + + return len; +} diff --git a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c index b4f1bd54b9..a1ac3a41da 100644 --- a/xen/common/dom0_ops.c +++ b/xen/common/dom0_ops.c @@ -412,6 +412,14 @@ long do_dom0_op(dom0_op_t *u_dom0_op) ret = 0; } break; + + case DOM0_READCONSOLE: + { + extern long read_console_ring(char *, unsigned int); + ret = read_console_ring(op.u.readconsole.str, + op.u.readconsole.count); + } + break; default: ret = -ENOSYS; diff --git a/xen/common/kernel.c b/xen/common/kernel.c index 6db936a3d7..8e2b7a7d49 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -156,6 +156,7 @@ void cmain (unsigned long magic, multiboot_info_t *mbi) } init_serial(); + init_console_ring(); init_vga(); cls(); @@ -447,12 +448,27 @@ void putchar_console(int c) {} #endif +#ifdef CONFIG_OUTPUT_CONSOLE_RING + +void putchar_console_ring(int c) +{ + if (console_ring.len < CONSOLE_RING_SIZE) + console_ring.buf[console_ring.len++] = (char)c; +} + +#else + +void putchar_console_ring(int c) {} + +#endif + static void putchar(int c) { if ( (c != '\n') && ((c < 32) || (c > 126)) ) return; putchar_serial(c); putchar_console(c); + putchar_console_ring(c); } diff --git a/xen/include/hypervisor-ifs/dom0_ops.h b/xen/include/hypervisor-ifs/dom0_ops.h index 7c0624b1d2..134eb82ddf 100644 --- a/xen/include/hypervisor-ifs/dom0_ops.h +++ b/xen/include/hypervisor-ifs/dom0_ops.h @@ -185,6 +185,17 @@ typedef struct dom0_settime_st u64 system_time; } dom0_settime_t; +/* + * Read console content from Xen buffer ring. + */ + +#define DOM0_READCONSOLE 19 +typedef struct dom0_readconsole_st +{ + char *str; + unsigned int count; +} dom0_readconsole_t; + typedef struct dom0_op_st { unsigned long cmd; @@ -205,6 +216,7 @@ typedef struct dom0_op_st dom0_msr_t msr; dom0_debug_t debug; dom0_settime_t settime; + dom0_readconsole_t readconsole; } u; } dom0_op_t; diff --git a/xen/include/xeno/console.h b/xen/include/xeno/console.h index 9d61754ae8..aff4814382 100644 --- a/xen/include/xeno/console.h +++ b/xen/include/xeno/console.h @@ -37,7 +37,21 @@ * yet, so this will do for now. */ -#define CONFIG_OUTPUT_CONSOLE 1 #define CONFIG_OUTPUT_SERIAL 1 +#define CONFIG_OUTPUT_CONSOLE 1 +#define CONFIG_OUTPUT_CONSOLE_RING 1 extern int opt_console; + +#define CONSOLE_RING_SIZE 16392 + +typedef struct console_ring_st +{ + char buf[CONSOLE_RING_SIZE]; + unsigned int len; +} console_ring_t; + +console_ring_t console_ring; + +void init_console_ring(); +long read_console_ring(char *str, unsigned int count); -- 2.30.2